﻿using System;

namespace DimMock
{
    /// <summary>
    /// Represents errors that occur in the DimMock framework.
    /// </summary>
    [Serializable]
    public class MockException : Exception
    {
        /// <summary>
        /// The default error message to throw when none are specified.
        /// </summary>
        private const String defaultMessage = "A mocking exception has occurred";
        /// <summary>
        /// Initializes a new instance of the <see cref="MockException"/> class.
        /// </summary>
        public MockException() : base(defaultMessage) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public MockException(String message) : base(message) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public MockException(String message, Exception innerException) : base(message, innerException) { }
    }

    /// <summary>
    /// Represents errors that occur when working with constructors on mock object types. 
    /// </summary>
    [Serializable]
    public class MockInitializationException : MockException
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MockInitializationException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public MockInitializationException(String message) : base(message) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockInitializationException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="messageParameters">The message parameters.</param>
        public MockInitializationException(String message, params Object[] messageParameters) : base(String.Format(message, messageParameters)) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockInitializationException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public MockInitializationException(String message, Exception innerException) : base(message, innerException) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockInitializationException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        /// <param name="messageParameters">The message parameters.</param>
        public MockInitializationException(String message, Exception innerException, params Object[] messageParameters) : base(String.Format(message, messageParameters), innerException) { }
    }

    /// <summary>
    /// Represents errors that occur when mock values are being generated.
    /// </summary>
    [Serializable]
    public class MockRandomValueException : MockException
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MockRandomValueException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        public MockRandomValueException(String message) : base(message) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockRandomValueException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="messageParameters">The message parameters.</param>
        public MockRandomValueException(String message, params Object[] messageParameters) : base(String.Format(message, messageParameters)) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockRandomValueException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        public MockRandomValueException(String message, Exception innerException) : base(message, innerException) { }
        /// <summary>
        /// Initializes a new instance of the <see cref="MockRandomValueException"/> class.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="innerException">The inner exception.</param>
        /// <param name="messageParameters">The message parameters.</param>
        public MockRandomValueException(String message, Exception innerException, params Object[] messageParameters) : base(String.Format(message, messageParameters), innerException) { }
    }
}
